<?php

namespace App\Http\Middleware;
use App\Models\User;
use App\Utils\CodeUtil;
use Closure;
class Login {
	/**
	 * Handle an incoming request.
	 *
	 * @param  \Illuminate\Http\Request $request
	 * @param  \Closure $next
	 * @return mixed
	 */
	public function handle($request, Closure $next) {
		if (session('admin_user')) {
			//User::where('id', session('uid'))->update(['last_login' => date('Y-m-d H:i:s', time())]);
			return $next($request);
		} else {
            return redirect("/api/login");
		}
	}
}
